home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / kant-generator-04-c / Kant ƒ / Shell ƒ / generic open.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  1.4 KB  |  66 lines  |  [TEXT/MMCC]

  1. #include "program globals.h"
  2. #include "graphics.h"
  3. #include "generic open.h"
  4. #include "kant load-save.h"
  5. #include "kant text twiddling.h"
  6. #include "environment.h"
  7. #include "dialogs.h"
  8. #include "error.h"
  9. #include "print meat.h"
  10.  
  11. void OpenTheFile(FSSpec *myFSS)
  12. {
  13.     switch (GetFileType(myFSS))
  14.     {
  15.         case SAVE_TYPE:
  16.             if (!GetIndWindowPtr(kMainWindow))
  17.             {
  18.                 saveFile=*myFSS;
  19.                 GetTheFile(&saveFile);
  20.                 gNeedToOpenWindow=FALSE;
  21.             }
  22.             else
  23.             {
  24.                 PositionDialog('ALRT', smallAlert);
  25.                 ParamText("\pPlease close the current text before opening another.","\p","\p","\p");
  26.                 StopAlert(smallAlert, 0L);
  27.             }
  28.             break;
  29.     }
  30. }
  31.  
  32. void PrintTheFile(FSSpec *myFSS)
  33. {
  34.     switch (GetFileType(myFSS))
  35.     {
  36.         case SAVE_TYPE:
  37.             if (!GetIndWindowPtr(kMainWindow))
  38.             {
  39.                 GetTheFile(myFSS);
  40.                 PrintText(GetTheTextHandle());
  41.                 CloseTheIndWindow(kMainWindow);
  42.             }
  43.             else
  44.             {
  45.                 PositionDialog('ALRT', smallAlert);
  46.                 ParamText("\pPlease close the current text before printing.","\p","\p","\p");
  47.                 StopAlert(smallAlert, 0L);
  48.             }
  49.             break;
  50.     }
  51. }
  52.  
  53. OSType GetFileType(FSSpec *myFSS)
  54. {
  55.     HParamBlockRec    paramBlock;
  56.     
  57.     paramBlock.fileParam.ioCompletion=0L;
  58.     paramBlock.fileParam.ioNamePtr=myFSS->name;
  59.     paramBlock.fileParam.ioVRefNum=myFSS->vRefNum;
  60.     paramBlock.fileParam.ioFDirIndex=0;
  61.     paramBlock.fileParam.ioDirID=myFSS->parID;
  62.     PBHGetFInfo(¶mBlock, FALSE);
  63.  
  64.     return paramBlock.fileParam.ioFlFndrInfo.fdType;
  65. }
  66.